<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <c:set var="ctx" value="${pageContext.request.contextPath }"></c:set>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<title>华阳物流</title>
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/bootstrap.min.css"/>	
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/public.css"/>
		<script src="<%=request.getContextPath()%>/resources/js/jquery-1.7.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="<%=request.getContextPath()%>/resources/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body class="huayang">
		<header class="clearfix">
			<a class="navbar-brand d-inline logo2" href="#"><img src="<%=request.getContextPath()%>/resources/img/logo.png"></a>
			<a class="navbar-brand d-inline logo3" href="#"><img src="<%=request.getContextPath()%>/resources/img/1.png"></a>
		</header>
		<div class="clearfix">
			
		</div>
        <nav class="navbar navbar-expand-lg navbar-light bg-light">
            <!--<a class="navbar-brand" href="#">Navbar</a>-->
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse" id="navbarSupportedContent">
           	
              <ul class="navbar-nav mr-auto">
              	<div class="container">       	
            	<div class="row clearfix">
              	<li class="nav-item active col-xs-6">
                  <a class="nav-link nav1" href="${ctx }/department/chengCity?deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
                <li class="nav-item active col-xs-6">
                  <a class="nav-link nav2" href="${ctx }/department/mianCity?deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
                 <li id="mz" class="nav-item active col-xs-6">
                  <a class="nav-link nav6" href="${ctx }/department/mzCity?deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
                <li class="nav-item active col-xs-6">
                  <a class="nav-link nav3" href="${ctx }/after/showAfter?pageNow=1&&deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
                <li class="nav-item active col-xs-6">
                 <a class="nav-link nav4" href="${ctx }/accountlist/selectAccountList?deptid=${deptid}&&rolename=${role.rolename}&deptname=&zhiling=&chexing=&xingming=&jiesuan=&jiashiyuanjs=&fatime1=&fatime2="><span></span></a>
                </li>
                <li class="nav-item active col-xs-6 current">
                  <a class="nav-link nav5" href="${ctx }/back/guanli?deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
               </div>
              </div>
              </ul>
            <div class="clearfix"></div>
            <ul class="nav justify-content-center fixed-top align-middle clearfix ">
			  <li class="nav-item">
                <img class="user-img rounded-circle" src="<%=request.getContextPath()%>/resources/img/raw_1514434504.jpg"/>  
              </li>
              <li class="nav-item user-info">
                <span>${user.uname}</span>    
                <span>${role.rolename}</span> 
              </li>
              <li class="nav-item pwd-change">
                <a class="nav-link active align-text-bottom" href="${ctx }/tuser/pwdjsp?deptid=${deptid}&&rolename=${role.rolename}">修改密码</a>                
              </li>
              <li class="nav-item exit"> 
              	<a href="${ctx }/back/userLoginOut" onclick="return confirm('您确定要退出系统吗？');" class="nav-link active"><span class="px-3">
					<img src="<%=request.getContextPath()%>/resources/img/exit.png"></span>退出</a>     
              </li>
            </ul>
          </div>       
        </nav>	
        <div class="container-fluid content">
        	<div class="row">
        		<div class="page_position d-none d-sm-block">
        			<!--位置-->
        			<!-- <div class="container-fluid pl-5">
        				<div class="row py-3">
        					<a href="#">绵阳</a>>><a href="#">新增售后</a>
        				</div>
        			</div> -->
        		</div>
        			<div class="container-fluid pl-xl-5 pt-xl-5 p-05">
		                	<div class="title text-center float-left">
			                	<a href="${ctx }/tuser/showUser?pageNow=1" class="btn btn-block"><span>查看所有用户</span></a>
			                </div>
        				<div class="row pt-4 col-12 col-sm-12 col-lg-9 col-xl-10 p-0">
        				   <div class="container" id="contet-box">
        				   	<!--运单登记-->
        				   	<div class="row clearfix">
		                    <div class="container_form ">
		                	
		                	
		                	
			                <form action="/huayang/tuser/userAdd" method="post"  onsubmit="return accoutest()" role="form" class="col-center-block">
			                	<div class="col-lg-6 form-group input-group-three">
			                	<p class="text-left">用户添加</p>
			                	<div class="input-group">
								    <div class="input-group-addon">账号：</div>
                                    <input type="text" name="username" id="username" class="form-control">
							    </div>
				                <div class="input-group">
								    <div class="input-group-addon">密码：</div>
                                    <input type="text" name="pwd"  id="pwd" class="form-control">
							    </div>
				                <div class="input-group">
								    <div class="input-group-addon">姓名：</div>
                                    <input type="text" name="realname"    id="realname" class="form-control timepick">
							    </div>
							    
							  
				                 <div class="form-group clearfix">
				                     <label class="radio-inline radio_class">
                                                                               权限管理：
                                     </label>
                                     <div class="radio_content clearfix "> 
					                 <c:forEach var="r" items="${rs}"   > 
					                          <label class="radio-inline">
                                     	  	<input type="radio" name="permissionsRadioOptions"    onclick="setYincang(${r.roleid})"  id="roleid" value="${r.roleid}"> ${r.rolename}
                                    		 </label>
									  </c:forEach>
                                     </div>
				                </div>
				                
				                  <div class="form-group clearfix"     id="bumen"       >
				                     <label class="radio-inline radio_class">
                                                                               部门：
                                     </label>
                                     <div class="radio_content clearfix ">    
										 <c:forEach var="dep" items="${deps}"   > 
					                          <label class="radio-inline">
                                      			 <input type="radio" name="inlineRadioOptions" id="depid" value="${dep.deptid}"> ${dep.deptname}
                                   			  </label>
										</c:forEach>
                                     </div>
				                </div>

				                </div>
				                <div class="clearfix"></div>
				                <div class="form-group detail-button clearfix">
					                <div class="float-left">
						               <button type="submit" class="btn btn-default">提交</button>
						            </div>
                                    <div class="float-right">
                                       <button type="button" class="btn btn-default" onClick="history.back();">取消</button>
                                    </div>
				                </div>
				                
			                </form>
			               
		                </div>          
		            </div>
        				   	<!--运单登记-->
        					</div>
        				</div>       				
        			</div>
        		</div>
        	</div> 
        
        	<!--推送消息-->
        	
        		<jsp:include page="munetab.jsp" />
        	
	</body>
	<script type="text/javascript">
	
		function   setYincang( index  ){
			if(index==4){
				document.getElementById("bumen").style.display="none";//隐藏
			}
			if(index!=4){
				document.getElementById("bumen").style.display="";//显示
			}
			
		} 
	
		function accoutest(){
			var username = document.getElementById("username").value;
			var pwd = document.getElementById("pwd").value;
			var realName = document.getElementById("realname").value;
			
			if(username==null||username==""||username==undefined){
				alert("请输入账号");
				return false;
			}
			if(pwd==null||pwd==""||pwd==undefined){
				alert("请输入密码");
				return false;
			}
			if(realName==null||realName==""||realName==undefined){
				alert("请输入姓名");
				return false;
			}
            var val=$('input:radio[name="permissionsRadioOptions"]:checked').val();
            if(val==null){
                alert("请选择用户权限!");
                return false;
            }
            
            if(val!=4) {
             	  	var list= $('input:radio[name="inlineRadioOptions"]:checked').val();
		            if(list==null){
		                alert("请选中一个用户部门!");
		                return false;
		            }
            }
			
			var   boo='';
			$.ajax({
		                url : '<%=basePath%>tuser/userRenameTest',
		                data:{user: username,},
		                type : 'post',
		                dataType : 'json',
		                async : false,
		                success : function(data) {
		                       if(data!=null){
		                          if(data.result=='1'){
		                          		alert("您输入的用户名已经存在，无法添加。");
		                          		boo='a';
		                          		return  false;
		                          } 
		                           if(data.result=='0'){
		                           		boo='b';
		                          		return  true;
		                          } 
		                       }                                                    
		                }
		         })
		         if(boo=='a'){
		        	 return  false;
		         }
		}
	</script>
	<script type="text/javascript"> 
		   window.onload=function(){ 
				var action ='<%=request.getAttribute("result")%>';
				if(action.length!==4)
				{
						alert(action);
				}
			} 
		</script>
</html>
